home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / tclX6.4c / dist / tests / forfile.test < prev    next >
Encoding:
Text File  |  1992-11-07  |  1.4 KB  |  45 lines

  1. #
  2. # forfile.test
  3. #
  4. # Tests for tcl.tlib for_file routine.
  5. #---------------------------------------------------------------------------
  6. # Copyright 1992 Karl Lehenbauer and Mark Diekhans.
  7. #
  8. # Permission to use, copy, modify, and distribute this software and its
  9. # documentation for any purpose and without fee is hereby granted, provided
  10. # that the above copyright notice appear in all copies.  Karl Lehenbauer and
  11. # Mark Diekhans make no representations about the suitability of this
  12. # software for any purpose.  It is provided "as is" without express or
  13. # implied warranty.
  14. #------------------------------------------------------------------------------
  15. # $Id: forfile.test,v 2.0 1992/10/16 04:49:49 markd Rel $
  16. #------------------------------------------------------------------------------
  17. #
  18.  
  19. if {[info procs test] == ""} then {source testlib.tcl}
  20.  
  21. rename SAVED_UNKNOWN unknown
  22.  
  23. set outfp [open FORFILE.TMP w]
  24. puts $outfp line1
  25. puts $outfp line2
  26. puts $outfp line3
  27. close $outfp
  28. unset outfp
  29.  
  30. test for_file-1.1 {for_file command} {
  31.     for_file line FORFILE.TMP {lappend result $line}
  32.     list $result
  33. } {{line1 line2 line3}}
  34.  
  35. test for_file-1.2 {errors in for_file command} {
  36.     string tolower [list [catch {for_file line _non_existent_ {echo $line}} \
  37.        msg] $msg $errorCode]
  38. } {1 {couldn't open "_non_existent_": no such file or directory} \
  39. {unix enoent {no such file or directory}}}
  40.  
  41. catch {unlink FORFILE.TMP}
  42.  
  43. unset result
  44. rename unknown SAVED_UNKNOWN
  45.